package package1.week1;

import java.util.Locale;

/**
 * @ClassName : Student
 * @Author : 骆发茂
 * @Date: 2021/10/14 8:33
 * @Description :
 */
public class Student {
    private String name;

    public Student(String name) {
        this.name = name;
    }

    /*覆盖重写父类的方法*/
    @Override
    public boolean equals(Object student) {
        /*如果是同一个对象，就不用比较，直接true*/
        if (this == student) {
            return true;
        }

        /*如果是空值，就false*/
        if (student == null) {
            return true;
        }

        /*如果对象的类都不相同，就不用比较了，直接false*/
        if (this.getClass() != student.getClass()) {
            return false;
        }


        /*不区分大小写比较值*/
        Student another = (Student) student;
        return this.name.toLowerCase(Locale.ROOT).equals(another.name.toLowerCase());
    }
}
